package com.wwj.core.pay.weixin;

import com.wwj.utils.PropertiesUtils;
import org.springframework.core.io.ClassPathResource;

/**
 * User: rizenguo
 * Date: 2014/10/29
 * Time: 14:40
 * 这里放置各种配置数据
 */
public class Configure {


//这个就是自己要保管好的私有Key了（切记只能放在自己的后台代码里，不能放在任何可能被看到源代码的客户端程序中）
    // 每次自己Post数据给API的时候都要用这个key来对所有字段进行签名，生成的签名会放在Sign这个字段，API收到Post数据的时候也会用同样的签名算法对Post过来的数据进行签名和验证
    // 收到API的返回的时候也要用这个key来对返回的数据算下签名，跟API的Sign数据进行比较，如果值不一致，有可能数据被第三方给篡改

    private static String key = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.key");

    //微信分配的公众号ID（开通公众号之后可以获取到）
    public static String appID = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.app_id");

    private static String appSecret = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.app_secret");


    //测试用
    //微信分配的公众号ID（开通公众号之后可以获取到）
    //public static String appID = "wxadd5aa0301057bcf";
    //private static String appSecret = "9a6d101d5d2b50923af6ae4093332e8c";


    //微信支付分配的商户号ID（开通公众号的微信支付功能之后可以获取到）
//	public static String mchID = "1373505702"; //weigee
    public static String mchID = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.mch_id");

    //受理模式下给子商户分配的子商户号
    private static String subMchID = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.sub_mch_id");

    //HTTPS证书的本地路径
//	public static String certLocalPath = "http://b.x.ifengtui.com/5tvc/apiclient_cert.p12";
    public static String certLocalPath = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.cert_local_path");

    //HTTPS证书密码，默认密码等于商户号MCHID
    private static String certPassword = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.cert_password");

    //是否使用异步线程的方式来上报API测速，默认为异步模式
    private static boolean useThreadToDoReport = true;

    //机器IP
    private static String ip = "";

    //以下是几个API的路径：
    //0) 统一下单
    public static String UNIFIED_ORDER_API = "https://api.mch.weixin.qq.com/pay/unifiedorder";
    //1）被扫支付API
    public static String PAY_API = "https://api.mch.weixin.qq.com/pay/micropay";

    //2）被扫支付查询API
    public static String PAY_QUERY_API = "https://api.mch.weixin.qq.com/pay/orderquery";

    //3）退款API
    public static String REFUND_API = "https://api.mch.weixin.qq.com/secapi/pay/refund";

    //4）退款查询API
    public static String REFUND_QUERY_API = "https://api.mch.weixin.qq.com/pay/refundquery";

    //5）撤销API
    public static String REVERSE_API = "https://api.mch.weixin.qq.com/secapi/pay/reverse";

    //6）下载对账单API
    public static String DOWNLOAD_BILL_API = "https://api.mch.weixin.qq.com/pay/downloadbill";

    //7) 统计上报API
    public static String REPORT_API = "https://api.mch.weixin.qq.com/payitil/report";

    //8)重定向到钱包页面URL    ktvadmin.weigee.net
    public static String REDIRECT_WALLET_URL = "http://test-weigee.ballq.cn/api/wallet/"; //测试
//	public static String REDIRECT_WALLET_URL = "http://ktvadmin.weigee.net/api/wallet/"; //正式服

    //9)生成openId后的回调url
    public static String OPENID_CALLBACK_URL = "http://test-weigee.ballq.cn/api/wechat/callBack.do"; //测试
//	public static String OPENID_CALLBACK_URL = "http://ktvadmin.weigee.net/api/wechat/callBack.do";

    //10)支付回调url
    public static String PAY_CALLBACK_URL = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.pay_callback_url");

    //11) 企业付款
    public final static String TRANSFAER_API = "https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers";

    public static boolean isUseThreadToDoReport() {
        return useThreadToDoReport;
    }

    public static void setREDIRECT_WALLET_URL(String rEDIRECT_WALLET_URL) {
        REDIRECT_WALLET_URL = rEDIRECT_WALLET_URL;
    }

    public static void setOPENID_CALLBACK_URL(String oPENID_CALLBACK_URL) {
        OPENID_CALLBACK_URL = oPENID_CALLBACK_URL;
    }

    public static void setPAY_CALLBACK_URL(String pAY_CALLBACK_URL) {
        PAY_CALLBACK_URL = pAY_CALLBACK_URL;
    }

    public static void setUseThreadToDoReport(boolean useThreadToDoReport) {
        Configure.useThreadToDoReport = useThreadToDoReport;
    }

    public static String HttpsRequestClassName = "com.tencent.common.HttpsRequest";

    public static void setKey(String key) {
        Configure.key = key;
    }

    public static void setAppID(String appID) {
        Configure.appID = appID;
    }

    public static void setAppSecret(String appSecret) {
        Configure.appSecret = appSecret;
    }

    public static void setMchID(String mchID) {
        Configure.mchID = mchID;
    }

    public static void setSubMchID(String subMchID) {
        Configure.subMchID = subMchID;
    }

    public static void setCertLocalPath(String certLocalPath) {
        Configure.certLocalPath = certLocalPath;
    }

    public static void setCertPassword(String certPassword) {
        Configure.certPassword = certPassword;
    }

    public static void setIp(String ip) {
        Configure.ip = ip;
    }

    public static String getKey() {
        return key;
    }

    public static String getAppID() {
        return appID;
    }

    public static String getAppSecret() {
        return appSecret;
    }

    public static String getMchID() {
        return mchID;
    }

    public static String getSubMchid() {
        return subMchID;
    }

    public static String getCertLocalPath() {
        return certLocalPath;
    }

    public static String getCertPassword() {
        return certPassword;
    }

    public static String getIP() {
        return ip;
    }

    public static void setHttpsRequestClassName(String name) {
        HttpsRequestClassName = name;
    }

//    public static void main(String[] args) {
//        String a = new PropertiesUtils(new ClassPathResource("core-resource.properties")).get("wx.key");
//        System.out.println(a);
//    }

}
